﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Cstudy.DAL
{
    public class link
    {
        /// <summary>
        /// 添加链接
        /// </summary>
        /// <param name="link"></param>
        /// <returns></returns>
        public bool AddLink(Cstudy.MODEL.link link)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@link_name",link.link_name),
                new SqlParameter("@link_url",link.link_url),
                new SqlParameter("@link_remark",link.link_remark),
                new SqlParameter("@link_order",link.link_order)
            };
            return COM.SQLHelper.ExecuteNonQuery("sp_AddLink", parms);
        }
        /// <summary>
        /// 删除链接
        /// </summary>
        /// <param name="link_id">链接ID</param>
        /// <returns></returns>
        public bool DeleteLink(int link_id)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@link_id",link_id)
            };
            return COM.SQLHelper.ExecuteNonQuery("sp_DeleteLink", parms);
        }
        /// <summary>
        /// 修改链接
        /// </summary>
        /// <param name="link">链接实体</param>
        /// <returns></returns>
        public bool UpdateLink(Cstudy.MODEL.link link)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@link_id",link.link_id),
                new SqlParameter("@link_name",link.link_name),
                new SqlParameter("@link_url",link.link_url),
                new SqlParameter("@link_remark",link.link_remark),
                new SqlParameter("@link_order",link.link_order)
            };
            return COM.SQLHelper.ExecuteNonQuery("sp_UpdateLink", parms);
        }
        /// <summary>
        /// 查询所有链接
        /// </summary>
        /// <returns></returns>
        public DataSet SelectLink()
        {
            return COM.SQLHelper.ExecuteQuery("sp_SelectLink");
        }
        /// <summary>
        /// 查询单条链接
        /// </summary>
        /// <param name="link_id">链接ID</param>
        /// <returns></returns>
        public DataSet SelectLinkByID(int link_id)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@link_id",link_id)
            };
            return COM.SQLHelper.ExecuteQuery("sp_SelectLinkByID", parms);
        }
    }
}
